﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ASRSubsDownloader.Common
{
    public interface IExceptionHandler
    {
        void Debug(string text);

        void Warn(string text);

        void Error(string text);
        void Error(Exception ex);
    }

    public class ExceptionHandler : IExceptionHandler
    {
        public void Debug(string text)
        {
            EventLog.WriteEntry("ASRSubtitlesDownload", text, EventLogEntryType.Information);
        }

        public void Warn(string text)
        {
            EventLog.WriteEntry("ASRSubtitlesDownload", text, EventLogEntryType.Warning);
        }

        public void Error(string text)
        {
            EventLog.WriteEntry("ASRSubtitlesDownload", text, EventLogEntryType.Error);
        }

        public void Error(Exception ex)
        {
            Error(ex.ToString());
        }
    }

}
